package producer_consumer;

import java.util.concurrent.ArrayBlockingQueue;

public class Consumer1 implements Runnable { // 实现接口来实现线程
	private ArrayBlockingQueue<Baozi> abq = null;// 定义一个空集合

	public Consumer1(ArrayBlockingQueue<Baozi> abq) {
		this.abq = abq;
	}

	@Override
	public void run() {
		while (true) {
			try {
				Baozi bz = abq.take();//移除abq集合里面的数据
				System.out.println("消费了" + bz.toString());
			} catch (InterruptedException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
